import service from "@/utils/request";
import type { IRes, IResPage } from "./api";

export interface IBaseTrademark {
  id: number;
  tmName: string;
  logoUrl: string;
}

/**
 *
 * @param page 当前页码
 * @param limit 每页显示条数
 * @returns IResPage
 */
export function requestBaseTrademarkByPage(page = 1, limit = 5) {
  return service.get<any, IResPage<IBaseTrademark>>(
    `/product/baseTrademark/${page}/${limit}`
  );
}

/**
 *
 * @param data
 * Omit<IBaseTrademark, "id"> => interface xx {tmName: string; logoUrl: string}
 */
export function requestSaveBaseTrademark(data: Omit<IBaseTrademark, "id">) {
  return service.post<any, null>("/product/baseTrademark/save", data);
}

export function requestUpdateBaseTrademark(data: IBaseTrademark) {
  return service.put<any, null>("/product/baseTrademark/update", data);
}

export function requestRemoveBaseTrademark(id: number) {
  return service.delete(`/product/baseTrademark/remove/${id}`);
}

//获取所有品牌数据
export function requestBaseTrademarks() {
  return service.get<any, IBaseTrademark[]>(
    "/product/baseTrademark/getTrademarkList"
  );
}
